﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ENG.EngStartQueueLib
{
 public class LinkReference : Reference
 {
   #region Properties

   [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
    private string _LinkFileName;
    ///<summary>
    /// Sets/gets LinkFileName value.
    ///</summary>
    public string LinkFileName
    {
      get
      {
        return (_LinkFileName);
      }
      set
      {
        _LinkFileName = value;
      }
    }
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
    private string _Description;
    ///<summary>
    /// Sets/gets Description value.
    ///</summary>
    public string Description
    {
      get
      {
        return (_Description);
      }
      set
      {
        _Description = value;
      }
    }
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
    private System.Windows.Forms.Keys _Hotkey;
    ///<summary>
    /// Sets/gets Hotkey value.
    ///</summary>
    public System.Windows.Forms.Keys Hotkey
    {
      get
      {
        return (_Hotkey);
      }
      set
      {
        _Hotkey = value;
      }
    }

    public override string Source
    {
      get
      {
        return LinkFileName;
      }
    }

   #endregion Properties

    private LinkReference() { }

    public static LinkReference Create(string linkFile)
   {
     LinkReference ret = new LinkReference();

     if (! System.IO.File.Exists(linkFile))
       throw new System.IO.FileNotFoundException(linkFile);

     ShellLink.ShellShortcut shortCut = new EngStartQueueLib.ShellLink.ShellShortcut(linkFile);

     ret.LinkFileName = linkFile;
     Reference r = (Reference)ret;
     Reference.AnalysePath(shortCut.Path, ref r);
     ret.Arguments = shortCut.Arguments;
     ret.WorkingDirectory = shortCut.WorkingDirectory;
     ret.Description = shortCut.Description;
     ret.Hotkey = shortCut.Hotkey;
     ret.WindowStyle = shortCut.WindowStyle;

     return ret;
   }
  }
}
